<template>
  <j-modal
    :title="'原材料盘库 - ' + title"
    :width="width"
    :visible="visible"
    :maskClosable="false"
    :keyboard="false"
    draggable
    switchFullscreen
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">

    <template slot="footer">
      <!-- 详情模式下只显示关闭按钮 -->
      <template v-if="action === 'detail'">
        <a-button @click="handleCancel" type="primary">关闭</a-button>
      </template>
      <!-- 非详情模式下显示取消和提交按钮 -->
      <template v-else>
        <a-button @click="handleCancel">取消</a-button>
        <a-button v-if="!disableSubmit" key="submit" @click="handleSubmit" type="primary">提交</a-button>
      </template>
    </template>
    <matcheck-form ref="realForm" @ok="submitCallback" :disabled="disabled" :action="action"/>
  </j-modal>
</template>

<script>
// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import matcheckForm from './MatcheckForm.vue'
  import { OrderModalMixin } from '../../common/mixins/OrderModalMixin'

  export default {
    name: 'MatcheckModal',
    mixins: [OrderModalMixin],
    components: {matcheckForm},
    
    // 定义props接收属性
    props: {
      disabled: {
        type: Boolean,
        default: false
      },
      action: {
        type: String,
        default: 'add'
      }
    },

    data() {
      return {
        width: 1300
      }
    },
    
    // 监听action变化，确保子组件也能接收到最新的action值
    watch: {
      action(val) {
        if (this.$refs.realForm) {
          this.$refs.realForm.action = val;
        }
      }
    },
    
    // 组件挂载后，确保action正确传递给子组件
    mounted() {
      if (this.$refs.realForm) {
        this.$refs.realForm.action = this.action;
      }
    }
  }
</script>

<style scoped>
</style>

